package cc.lj.internal.mobilepay.interfaces.facade;

import cc.lj.internal.core.exception.SysExceptionEnum;
import cc.lj.internal.core.http.HttpResult;
import cc.lj.internal.mobilepay.application.service.PayAppService;
import cc.lj.internal.mobilepay.interfaces.dto.PayResponseDTO;
import cc.lj.internal.mobilepay.interfaces.dto.command.PayCommand;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.io.IOException;
import java.io.InputStream;
import java.util.Map;
import java.util.Properties;

/**
 * 统一支付接口
 * @author liangxifeng
 * @date 2021-12-20
 */
@RestController
@Slf4j
@Validated
@RequestMapping("pay")
public class PayController {
    @Resource(name = "payAppService")
    private PayAppService payAppService;

    /**
     * 主动扫码，请求支付
     * @param payCommand
     * @return
     */
    @PostMapping()
    public HttpResult<PayResponseDTO> doPay(@Valid @RequestBody PayCommand payCommand)
    {
        PayResponseDTO res = payAppService.doMain(payCommand);
        return HttpResult.success(SysExceptionEnum.SUCCESS.getCode(),SysExceptionEnum.SUCCESS.getMessage(),res);
    }
}
